package cn.catsdad.controller;

import cn.catsdad.auth.annotation.log.Log;
import cn.catsdad.base.controller.BaseCrudController;
import cn.catsdad.base.web.HttpResponse;
import cn.catsdad.constant.enumConstant.LogEnum;
import cn.catsdad.dto.DictDTO;
import cn.catsdad.dto.DictDetailDTO;
import cn.catsdad.page.DictParam;
import cn.catsdad.service.api.DictService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 常量管理
 *
 * @author xuyonglong
 * @version V1.0 2023/4/24
 */
@RestController
@RequestMapping("/api/system/dicts")
public class DictController extends BaseCrudController<DictDTO, Long, DictService, DictParam> {

    /**
     * 根据编码查询子级
     *
     * @param dictCode 父级编码
     * @return 子级列表
     */
    @Log(moduleName = "词典管理", logType = LogEnum.LogType.SYSTEM,
            operationType = LogEnum.OperationType.EXPORT, description = "查询子级字典数据")
    @GetMapping("/{dictCode}/dictDetails")
    public HttpResponse<List<DictDetailDTO>> queryChildren(@PathVariable("dictCode") String dictCode) {
        return new HttpResponse<List<DictDetailDTO>>().setData(service.queryChildrenByDictCode(dictCode));
    }

}